﻿using D.UtilCore;
using D.UtilCore.Dtos;
using D.UtilCore.Filters;
using Microsoft.AspNetCore.Mvc;
using CozeDomain.IServices;
using D.UtilFreesqlOrm;
using CozeDto.SysDicDtos;
using Microsoft.AspNetCore.Authorization;
using CozeDomain.Entities;
using CozeDomain.Services;
using CozeDto.ProjectDtos;

namespace CozeWapApi
{
    /// <summary>
    /// 字典模块
    /// </summary>
    [Route("/api/[controller]/[action]")]
    public class SysDicController : BaseApiController
    {
        private readonly ISysDicService _sysDicService;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="sysDicService"></param>
        public SysDicController(ISysDicService sysDicService)
        {
            _sysDicService = sysDicService;
        }
         
        /// <summary>
        /// 获取下拉
        /// </summary>
        /// <param name="dicTypeUniqueCode"></param>
        /// <returns></returns>
        [HttpGet, TypeFilter(typeof(ExtActionFilterAttribute))]
        [Authorize]
        public async Task<ApiResult<List<RepSelect>>> QueryDicSelect([FromQuery] string dicTypeUniqueCode)
        {
            return await _sysDicService.QueryDicSelect(dicTypeUniqueCode);
        }

        /// <summary>
        /// 获取下拉树
        /// </summary>
        /// <param name="dicTypeUniqueCode"></param>
        /// <returns></returns>
        [HttpGet, TypeFilter(typeof(ExtActionFilterAttribute))]
        [Authorize]
        public async Task<ApiResult<List<RepTreeSelect>>> QueryDicTreeSelect([FromQuery] string dicTypeUniqueCode)
        {
            return await _sysDicService.QueryDicTreeSelect(dicTypeUniqueCode);
        }

        /// <summary>
        /// 获取下拉树-2
        /// </summary>
        /// <param name="dicTypeUniqueCode"></param>
        /// <returns></returns>
        [HttpGet, TypeFilter(typeof(ExtActionFilterAttribute))]
        [Authorize]
        public async Task<ApiResult<List<RepTreeList>>> QueryDicTreeSelect2([FromQuery] string dicTypeUniqueCode)
        {
            return await _sysDicService.QueryDicTreeSelect2(dicTypeUniqueCode);
        } 
    }
}